﻿namespace Cos.Module.CMS.NHibernate
{
    using System;

    using Cos.Core.NHibernate;
    using Cos.Module.CMS.Data;

    using global::NHibernate;

    /// <summary>
    /// Site repository.
    /// </summary>
    public class SiteRepository : RepositoryBase, ISiteRepository
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SiteRepository"/> class.
        /// </summary>
        /// <param name="sessionFactory">The session factory.</param>
        public SiteRepository(ISessionFactory sessionFactory) 
            : base(sessionFactory)
        {
        }

        /// <summary>
        /// Gets the site last modification date.
        /// </summary>
        public DateTime SiteLastModificationDate
        {
            get
            {
                var query = CurrentSession.CreateSQLQuery("SELECT SiteLastModified AS res FROM Version");
                return query.UniqueResult<DateTime>();
            }
        }
    }
}
